//
//  orderDetailController.m
//  lv678
//
//  Created by apple on 15/7/23.
//  Copyright (c) 2015年 lampshade. All rights reserved.
//

#import "orderDetailController.h"
#import "AFNetworking.h"
#import "GZToDetail.h"
#import "UIImageView+WebCache.h"
#import "TicketOrderDetailController.h"
#import "CommonLoading.h"

@interface orderDetailController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *productNameLbl;
@property (weak, nonatomic) IBOutlet UILabel *priceLbl;
@property (weak, nonatomic) IBOutlet UIButton *priceAdvs;
@property (weak, nonatomic) IBOutlet UIButton *singUp;
@property (weak, nonatomic) IBOutlet UILabel *positionLbl;
@property (weak, nonatomic) IBOutlet UILabel *introductLbl;

@property (nonatomic,strong) GZToDetail *detail;
@property (nonatomic, weak) UIView *waitView;
@end

@implementation orderDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];
    [self getData];
}

- (void)initView{
    _singUp.layer.cornerRadius = 6;
    [self.navigationItem setTitle:@"订单"];
    [_priceAdvs addTarget:self action:@selector(pushViewController:animated:) forControlEvents:UIControlEventTouchUpInside];
    
    UIView *fontView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    UIView *view = [[CommonLoading initCommonLoading]refreshLoading];
    [fontView addSubview:view];

    self.waitView = fontView;
    [self.view addSubview:fontView];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

//获取数据
- (void)getData{
    NSString *path = [[NSBundle mainBundle]pathForResource:@"UrlList.plist" ofType:nil];
    NSDictionary *tempDic = [NSDictionary dictionaryWithContentsOfFile:path];
    NSString *url = [tempDic objectForKey:@"travelTicket"];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
    NSDictionary *date = @{@"queryParameters":@{@"tid":_tid}, @"serviceName":@"todetail"};
    [manager POST:url parameters:date success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [self.waitView removeFromSuperview];
            _detail = [GZToDetail detailWithDict:[responseObject valueForKey:@"dataList"]];
            _productNameLbl.text = _detail.productName;
            NSString *price = [NSString stringWithFormat:@"%@",_detail.price];
            _priceLbl.text = price;
            _positionLbl.text = _detail.address;
            _introductLbl.text = _detail.describe;
        [_imageView sd_setImageWithURL:[NSURL URLWithString:_image]];
            [_singUp addTarget:self action:@selector(pushViewController:animated:) forControlEvents:UIControlEventTouchUpInside];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error");
    }];
    
}
- (void)pushViewController:(UIViewController *)viewController
                  animated:(BOOL)animated{
    TicketOrderDetailController *view = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"order"];
    view.productName = _detail.productName;
    view.price = _detail.price;
    view.tid = _tid;
    [self.navigationController pushViewController:view animated:YES];
    
}


@end
